package com.cskaoyan.app.wxcontroller;

import com.cskaoyan.app.bean.bo.WxGoodsListBO;
import com.cskaoyan.app.bean.common.BaseRespVo;
import com.cskaoyan.app.bean.common.CommonData;
import com.cskaoyan.app.bean.po.MarketGoods;
import com.cskaoyan.app.bean.vo.wx.WxGoodsCategoryVO;
import com.cskaoyan.app.bean.vo.wx.WxGoodsDetailVO;
import com.cskaoyan.app.bean.vo.wx.WxGoodsListVO;
import com.cskaoyan.app.wxservice.WxGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("wx/goods")
public class WxGoodsController {

    @Autowired
    private WxGoodsService wxGoodsService;

    @GetMapping("count")
    public Object count() {
        Integer data = wxGoodsService.count();
        return BaseRespVo.ok(data);
    }

    @GetMapping("category")
    public Object category(Integer id) {
        WxGoodsCategoryVO data = wxGoodsService.category(id);
        return BaseRespVo.ok(data);
    }

    @GetMapping("list")
    public Object list(WxGoodsListBO info) {
        WxGoodsListVO data = wxGoodsService.list(info);
        return BaseRespVo.ok(data);
    }

    @GetMapping("related")
    public Object related(Integer id) {
        CommonData<MarketGoods> data = wxGoodsService.related(id);
        return BaseRespVo.ok(data);
    }

    @GetMapping("detail")
    public Object detail(Integer id) {
        WxGoodsDetailVO data = wxGoodsService.detail(id);
        return BaseRespVo.ok(data);
    }
}
